package com.example.login.mapper;

import org.apache.ibatis.annotations.*;
import org.example.bean.QuanxianInfo;
import org.example.bean.YongHuInfo;

import java.util.List;

@Mapper
public interface YongHuMapper {
    @Select("select * from yonghu where (niCheng=#{youxiang} or youXiang=#{youxiang} or shouJiHao=#{youxiang}) and miMa=#{mima} and zhuangTai=1")
    YongHuInfo findYongHuByMima(@Param("youxiang") String youxiang,@Param("mima") String mima);
    @Insert("insert into yonghu values(null,null,#{niCheng},null,null,null,#{miMa},null,#{quanXianId},1)")
    void saveYongHu(YongHuInfo yhi);
    @Select("select * from yonghu where  zhuangTai=1 limit #{start},#{size}")
    List<YongHuInfo> findAllYongHu(@Param("start") int start,@Param("size") int size);
    @Select("select count(yongHuId) from yonghu where  zhuangTai=1")
    int findAllCount();
    @Update("update yonghu set niCheng=#{niCheng},miMa=#{miMa},quanXianId=#{quanXianId} where yongHuId=#{yongHuId}")
    void UpdateYongHU(YongHuInfo yhi);
    @Update("update yonghu set zhuangTai=0 where yongHuId=#{yongHuId}")
    void deleteYongHU(int yongHuId);


    @Select("select * from quanxian")
    List<QuanxianInfo> findAllQuanXian();
    @Select("select * from quanxian where quanxianid=#{quanXianId}")
    QuanxianInfo findYongHuQuanXianById(int quanXianId);


}
